#ifndef HASHNODE_H
#define HASHNODE_H

#include "../debug.h"
#include "../config.h"

#ifdef DEBUG
#include <iostream>
using std::cout;
using std::endl;
#endif

class Hash_node
{
private:
    int item_id;
    Hash_node* hash_table[config::hash_num];
public:
    int M;                      // num of matched records
    int E;                      // num of error predicted
    float profit;
    float estimated;
    //rule counter
    static int rule_0;             // num of rules produced by fptree
    static int rule_1;             // num of rules pruned by pruning rules
    static int rule_2;             // num of rules pruned by pruning model

    Hash_node* parent;         // parent in hash tree
    Hash_node* c_par;           // parent in covering tree relationship
    Hash_node* first_child;     // first child in covering tree relationship
    Hash_node* sibling;        // sibling in covering tree
    
	bool no_other_child();
    void del_sub_covering_tree( Hash_node* p);
public:
    Hash_node(int i);
	~Hash_node();
	int get_id();
    int hash( int id );
    
	bool has_child( int id);
    Hash_node* get_child( int id );
    void add_child( Hash_node* mynode );
	void del_child( int id );    //delete a child,if it's a sub hash_tree,delete the sub tree
	bool prune_leaf( int id );
    bool is_root();
    bool is_leaf();
	bool is_psuedo_leaf();
	bool has_psuedo_leaf();
	Hash_node* get_psuedo_leaf();
    float rank();
    void depart_c_par();
    // covering tree operations
    float E_tree();             // estimated value of this sub tree
    float E_leaf();             // estimated value if this is a leaf
    void prune_to_leaf();
};
#endif
